package com.example.javanewwork.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.javanewwork.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.javanewwork.entity.User;
@Service
public class Userservice {


    @Autowired
    private UserMapper userMapper;

    public int save(User user)
    {
        if(user.getId()==null)
        {
           return userMapper.insert(user);
        }
        else {
            return userMapper.update(user);
        }
    }

    public boolean login(User user) {
        return userMapper.login(user);
    }

    public User findByUserName(String username) {
        return userMapper.findUserByname(username);
    }

    public void register(String username, String password) {
        userMapper.register(username,password);
    }

    public void Update(User user) {
        userMapper.updateUser(user);
    }
}
